package com.dw.etl.core.controller;

import javax.servlet.http.HttpServletRequest;

import com.dw.etl.common.base.BaseException;
import org.springframework.beans.factory.annotation.Autowired;
import  com.dw.etl.common.base.BaseResult;
import  com.dw.etl.common.constant.CommonResultConstant;
import com.dw.etl.core.api.EtlLogXxltobatchService;
import com.dw.etl.core.bean.model.EtlLogXxltobatch;
import org.springframework.util.StringUtils;
import  com.dw.etl.common.vo.PaginationVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * etlLogXxltobatch控制器
 * Created by hozeData on 2021/07/19.
 */
@RestController
@RequestMapping("/etl/etlLogXxltobatch/")
@Api(description="开发中", tags="开发中")
public class EtlLogXxltobatchController {

    @Autowired
    EtlLogXxltobatchService etlLogXxltobatchService;

    @ApiOperation(value="分页查询")
    @RequestMapping(value="findByPage", method=RequestMethod.POST)
    public BaseResult findByPage(@RequestBody EtlLogXxltobatch etlLogXxltobatch, Integer pageNum, Integer pageSize) {
        PaginationVO<EtlLogXxltobatch> pageVO = etlLogXxltobatchService.findPageByModel(etlLogXxltobatch, pageNum, pageSize);
        return new BaseResult(CommonResultConstant.SUCCESS, pageVO);
    }

    @ApiOperation(value="保存")
    @ApiImplicitParam(name="etlLogXxltobatch", value="实体", paramType="body", required=true, dataType="EtlLogXxltobatch")
    @RequestMapping(value="insert", method=RequestMethod.POST)
    public BaseResult insert(@RequestBody EtlLogXxltobatch etlLogXxltobatch, HttpServletRequest request)  {
        int num = etlLogXxltobatchService.insertSelective(etlLogXxltobatch);
        return new BaseResult(CommonResultConstant.SUCCESS, num);
    }

    @ApiOperation(value="详情")
    @ApiImplicitParam(name="id", value="主键", paramType="query", required=true, dataType="String")
    @RequestMapping(value="getById", method=RequestMethod.GET)
    public BaseResult getById(String id, HttpServletRequest request) throws BaseException {
        if(StringUtils.isEmpty(id)){
            throw new BaseException("请选择要编辑的项");
        }
        EtlLogXxltobatch etlLogXxltobatch = etlLogXxltobatchService.getById(id);
        return new BaseResult(CommonResultConstant.SUCCESS, etlLogXxltobatch);
    }

    @ApiOperation(value="修改")
    @ApiImplicitParam(name="etlLogXxltobatch", value="实体", paramType="body", required=true, dataType="EtlLogXxltobatch")
    @RequestMapping(value="update", method=RequestMethod.POST)
    public BaseResult update(@RequestBody EtlLogXxltobatch etlLogXxltobatch, HttpServletRequest request)  {
        int num = etlLogXxltobatchService.updateByIdSelective(etlLogXxltobatch);
        return new BaseResult(CommonResultConstant.SUCCESS, num);
    }

    @ApiOperation(value="根据主键删除")
    @ApiImplicitParam(name="id", value="主键", paramType="query", required=true, dataType="String")
    @RequestMapping(value="delete", method=RequestMethod.GET)
    public BaseResult delete(String id, HttpServletRequest request) throws BaseException {
        if(StringUtils.isEmpty(id)){
            throw new BaseException("请选择要删除的项");
        }
        int num = etlLogXxltobatchService.deleteById(id);
        return new BaseResult(CommonResultConstant.SUCCESS, num);
    }



}
